package ru.spb.osll.myfit.server;

import java.io.File;
import java.util.List;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import ru.spb.osll.myfit.common.MetadataColumnDef;


/**
 * User: Alexander Opeykin (alexander.opeykin@gmail.com)
 * Date: 5/21/12
 * Time: 3:02 PM
 */
public class MetadataConfigurator {
  private static final String CONFIG_FILE = "../conf/metadataConfig.xml";

  public List<MetadataColumnDef> readProp() throws PropertyReadException {
    XStream xstream = new XStream(new DomDriver());
    xstream.processAnnotations(MetadataColumnDef.class);

    try {
      @SuppressWarnings("unchecked")
      List<MetadataColumnDef> list = (List<MetadataColumnDef>)xstream.fromXML(new File(CONFIG_FILE));
      return list;
    } catch (Exception e) {
      throw new PropertyReadException(e.getMessage());
    }
  }
}
